#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Game main module.
#
#Sets up necessary modules and hands control over to the game module
#

import data
import default
import game
import sound
from menu import Menu
import effects

from pygame.locals import *
import pygame
import getopt
import sys

def setup_display(flags):
    try:
        pygame.init()
        pygame.display.set_mode(default.screen_size, flags)

        pygame.display.set_caption(default.window_caption)
        screen = pygame.display.get_surface()

        pygame.mouse.set_visible(False)
    except pygame.error, message:
        print "An error occurred. Could not initilialize pygame."
        raise SystemExit, message
    return screen

def main():
  
    flags = DOUBLEBUF | HWSURFACE
    try:
        optlist, args = getopt.getopt(sys.argv[1:], "f", ['fullscreen'])
    except getopt.GetoptError, err:
        print "You probably did something wrong. Do something right instead."
        sys.exit(0)
    
    for item in optlist:
        if item[0] == "-f" or item[0] == "fullscreen":
            flags = flags | FULLSCREEN
    
    screen = setup_display(flags)

    effects.prepare()
    
    #This is where IT SPINS OUT OF CONTROL AAAH!
    menu = Menu(screen)
    menu.run()
    
    
